<?php
$title = ___("Redirect to MoIP JavaScript payment .");
$this->setLayout('layout.phtml');
?>

<script type="text/javascript">
       var funcaoSucesso = function(data)
       {
           alert('Sucesso\n' + JSON.stringify(data));
           window.open(data.url);
       };

       var funcaoFalha = function(data)
       {
    	   alert('Falha\n' + JSON.stringify(data));  
       };

       processPaymentCreditCard = function()
       {
           var settings = {
               "Forma": "CartaoCredito",
               "Instituicao": "Visa",
               "CartaoCredito": {
                   "Numero": "",
                   "Expiracao": "",
                   "CodigoSeguranca": "",
                   "Portador": {
                       "Nome": "",
                       "DataNascimento": "",
                       "Telefone": "",
                       "Identidade": ""
                   }
               }
           }

           MoipWidget(settings);
       }
</script>
<div id="MoipWidget"
     data-toke="<?php echo $this->Token; ?>"
     callback-method-success="functionSucess"
     callbak-method-error="functionFallen"></div>
<button id="pagarCreditCard" onclick="processPaymentCreditCard()"> Imprimir CreditCard </button>
<script type="text/javascript" src='https://desenvolvedor.moip.com.br/sandbox/transparente/MoipWidget-v2.js'
charset=ISO-8859-1"></script>